package blt.app_core.http.callback;


import blt.app_core.http.request.ProgressListener;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by Administrator on 2016/12/13.
 */
public abstract class HttpCallback<T> implements ProgressListener {

    public void dispatchStart(final Request request) {
        onStart(request);
    }

    public void dispatchProgress(long current, long count) {
        onProgress(current, count);
    }

    public void dispatchFinish() {
        onFinish();
    }

    public void dispatchSuccess(T response, int code) {
        onSuccess(response, code);
    }

    public void dispatchFailure(Request request, Response response, Exception e) {
        onFailure(request, response, e);
    }


    public void onStart(Request request) {
    }

    public void onFinish() {
    }


    public void onProgress(long current, long count) {
    }

    public abstract void onFailure(Request request, Response response, Exception e);

    public abstract void onSuccess(T response, int code);

}
